<%-- 
    Document   : cliente
    Created on : 10/03/2014, 18:43:29
    Author     : jordan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cliente</title>
        <link rel="stylesheet" href="./css/cliente.css" type="text/css" />
    </head>
    <body>
        <c:import url="menu.jsp" />
        <c:set var="tipoUsuario" value=
            "<%=(
                session.getAttribute("tipoUsuario")
            )%>"/>
        <c:set var="id" value=
            "<%=(
                session.getAttribute("id")
            )%>"/>
        <c:if test="${id==null}">
            <c:redirect url="index.jsp?error=14,W;${id}"/>
        </c:if>
        <c:if test="${tipoUsuario!='2'}">
            <c:redirect url="index.jsp#${id}#"/>
        </c:if>
        <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/coleta_seletiva"
            user="root" password=""/>
        <sql:query dataSource="${snapshot}" var="result">
            SELECT *,  CAST(usuario.id as CHAR) as id_usuario, CAST(cliente.id as CHAR) as id_cliente
                FROM usuario
                LEFT JOIN cliente ON usuario.id = cliente.id
                WHERE usuario.id = ?
            <sql:param value="${id}"/>
        </sql:query>
        <c:if test="${result.rowCount<=0}">
            <c:redirect url="index.jsp"/>
        </c:if>
        <h1>Cliente</h1>
        <form action="confirmacaoCliente.jsp" method="post">
            <input type="hidden" id="idCliente" name="idCliente" value="${result.rows[0].id_cliente}"/>
            <input type="hidden" id="senhaAtual" name="senhaAtual" value="${result.rows[0].senha}"/>
            <fieldset style=" border: none; width: 85%">
                <div class="botao"><button name="retorna" value="retorna">Retornar</button></div>
            </fieldset>
            <fieldset style="border: 1px solid; width: 85%">
                <legend>Informações do Cliente</legend>
                <div class ="campos tc_curto">
                    Id:<br>
                    <input type="text" id="id" name="id" value="${result.rows[0].id_usuario}" readonly="readonly"/>
                </div>
                <div class ="campos tc_longo">
                    Nome do Cliente:<span class="asterisco">*</span><br>
                    <input type="text" id="nome" name="nome" value="${result.rows[0].nome}" />
                    
                </div>
                <div class ="campos tc_medio">
                    Login de Acesso:<span class="asterisco">*</span><br>
                    <input type="text" id="login" name="login" value="${result.rows[0].login}" />
                    
                </div>
                <div class ="campos tc_medio">
                    Senha:<br>
                    <input type="text" id="senha" name="senha" value="" />
                </div>
                <div class ="campos tc_medio">
                    Nova Senha:<br>
                    <input type="text" id="senhaNova" name="senhaNova" value="" />
                </div>
                <div class ="campos tc_medio">
                    Confirma Senha:<br>
                    <input type="text" id="senhaConfirma" name="senhaConfirma" value="" />
                </div>
                <div class ="campos tc_mlongo">
                    E-mail:<span class="asterisco">*</span><br>
                    <input type="text" id="email" name="email" value="${result.rows[0].e_mail}" />
                </div>
                <fieldset style="border: 1px solid; width: 98%">
                    <legend>Endereço</legend>
                    <div class ="campos tc_longo">
                        Logradouro:<br>
                        <input type="text" id="enderecoLogradouro" name="enderecoLogradouro" value="${result.rows[0].endereco_logradouro}" />
                    </div>
                    <div class ="campos tc_cmedio">
                        Número:<br>
                        <input type="text" id="enderecoNumero" name="enderecoNumero" value="${result.rows[0].endereco_numero}" />
                    </div>
                    <div class ="campos tc_medio">
                        Complemento:<br>
                        <input type="text" id="enderecoComplemento" name="enderecoComplemento" value="${result.rows[0].endereco_complemento}" />
                    </div>
                    <div class ="campos tc_medio">
                        Bairro:<span class="asterisco">*</span><br>
                        <input type="text" id="enderecoBairro" name="enderecoBairro" value="${result.rows[0].endereco_bairro}" />
                    </div>
                    <div class ="campos tc_cmedio">
                        C.E.P.:<span class="asterisco">*</span><br>
                        <input type="text" id="enderecoCep" name="enderecoCep" value="${result.rows[0].endereco_cep}" />
                    </div>
                    <div class ="campos tc_mlongo">
                        Cidade:<span class="asterisco">*</span><br>
                        <input type="text" id="enderecoCidade" name="enderecoCidade" value="${result.rows[0].endereco_cidade}" />
                    </div>
                    <div class ="campos tc_curto">
                        UF<span class="asterisco">*</span><br>
                        <select id="enderecoUf" name="enderecoUf">
                            <option value="--">Selecione</option>
                            <option value="AL"<c:if test="${result.rows[0].endereco_uf=='AL'}"> selected </c:if>>AL</option>
                            <option value="AP"<c:if test="${result.rows[0].endereco_uf=='AP'}"> selected </c:if>>AP</option>
                            <option value="AM"<c:if test="${result.rows[0].endereco_uf=='AM'}"> selected </c:if>>AM</option>
                            <option value="BA"<c:if test="${result.rows[0].endereco_uf=='BA'}"> selected </c:if>>BA</option>
                            <option value="CE"<c:if test="${result.rows[0].endereco_uf=='CE'}"> selected </c:if>>CE</option>
                            <option value="DF"<c:if test="${result.rows[0].endereco_uf=='DF'}"> selected </c:if>>DF</option>
                            <option value="ES"<c:if test="${result.rows[0].endereco_uf=='ES'}"> selected </c:if>>ES</option>
                            <option value="GO"<c:if test="${result.rows[0].endereco_uf=='GO'}"> selected </c:if>>GO</option>
                            <option value="MA"<c:if test="${result.rows[0].endereco_uf=='MA'}"> selected </c:if>>MA</option>
                            <option value="MT"<c:if test="${result.rows[0].endereco_uf=='MT'}"> selected </c:if>>MT</option>
                            <option value="MS"<c:if test="${result.rows[0].endereco_uf=='MS'}"> selected </c:if>>MS</option>
                            <option value="MG"<c:if test="${result.rows[0].endereco_uf=='MG'}"> selected </c:if>>MG</option>
                            <option value="PA"<c:if test="${result.rows[0].endereco_uf=='PA'}"> selected </c:if>>PA</option>
                            <option value="PB"<c:if test="${result.rows[0].endereco_uf=='PB'}"> selected </c:if>>PB</option>
                            <option value="PR"<c:if test="${result.rows[0].endereco_uf=='PR'}"> selected </c:if>>PR</option>
                            <option value="PE"<c:if test="${result.rows[0].endereco_uf=='PE'}"> selected </c:if>>PE</option>
                            <option value="PI"<c:if test="${result.rows[0].endereco_uf=='PI'}"> selected </c:if>>PI</option>
                            <option value="RJ"<c:if test="${result.rows[0].endereco_uf=='RJ'}"> selected </c:if>>RJ</option>
                            <option value="RN"<c:if test="${result.rows[0].endereco_uf=='RN'}"> selected </c:if>>RN</option>
                            <option value="RS"<c:if test="${result.rows[0].endereco_uf=='RS'}"> selected </c:if>>RS</option>
                            <option value="RO"<c:if test="${result.rows[0].endereco_uf=='RO'}"> selected </c:if>>RO</option>
                            <option value="RR"<c:if test="${result.rows[0].endereco_uf=='RR'}"> selected </c:if>>RR</option>
                            <option value="SC"<c:if test="${result.rows[0].endereco_uf=='SC'}"> selected </c:if>>SC</option>
                            <option value="SP"<c:if test="${result.rows[0].endereco_uf=='SP'}"> selected </c:if>>SP</option>
                            <option value="SE"<c:if test="${result.rows[0].endereco_uf=='SE'}"> selected </c:if>>SE</option>
                            <option value="TO"<c:if test="${result.rows[0].endereco_uf=='TO'}"> selected </c:if>>TO</option>
                        </select>
                    </div>
                    <div class ="campos tc_cmedio">
                    </div>
                    <div class ="campos tc_medio">
                        Telefone Residencial:<br>
                        <input type="text" id="telefoneResidencial" name="telefoneResidencial" value="${result.rows[0].telefone_residencial}" />
                    </div>
                    <div class ="campos tc_medio">
                        Telefone Comercial:<br>
                        <input type="text" id="telefoneComercial" name="telefoneComercial" value="${result.rows[0].telefone_comercial}" />
                    </div>
                    <div class ="campos tc_medio">
                        Telefone Celular:<br>
                        <input type="text" id="telefoneCelular" name="telefoneCelular" value="${result.rows[0].telefone_celular}" />
                    </div>
                    
                </fieldset>
                <span class="asterisco">Observação: Os campos marcados com asterisco são de preenchimento obrigatório. A senha somente será alterada quando for informada as três senhas.</span>
                <div class="botao"><button>Salvar Dados</button></div>
            </fieldset>
        </form>
        
    </body>
</html>
